import { apiGet, apiPost, apiPut, apiDelete } from './client'

export interface Course {
  id?: number
  code?: string
  name?: string
  credit?: number
  type?: string
}

export async function listCourses(params: { keyword?: string; offset?: number; limit?: number } = {}) {
  return apiGet<Course[]>('/api/grades/courses', params)
}

export async function getCourse(id: number) {
  return apiGet<Course>(`/api/grades/courses/${id}`)
}

export async function createCourse(course: Course) {
  return apiPost<Course>('/api/grades/courses', course)
}

export async function updateCourse(id: number, course: Course) {
  return apiPut<Course>(`/api/grades/courses/${id}`, course)
}

export async function deleteCourse(id: number) {
  return apiDelete<string>(`/api/grades/courses/${id}`)
}